//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.tuiofx;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public final class Configuration {
    private final int port;
    private boolean debugModeEnabled;
    private boolean useIndirectInputDevice;
    private boolean showCursor;
    private final double minimumInertiaVelocity;
    private final double scrollTouchSlopDP;
    private final double startRotation;
    private final double minRotation;
    private final long longPressDuration;
    private final double minZoomSpan;
    private final double startZoomSpan;
    private final int screenDevice;

    private boolean handlerCursorEvent;

    public static Configuration pqLabs() {
        return newBuilder().setMinimumInertiaVelocity(0.4).setScrollTouchSlopDP(0.01).setStartRotation(0.001).setMinRotation(0.0015).setLongPressDuration(400L).setMinZoomSpan(400.0).setStartZoomSpan(400.0).setIndirectInputDevice(false).setDebugModeEnabled(true).build();
    }

    public static Configuration ioS() {
        return newBuilder().setMinimumInertiaVelocity(0.4).setScrollTouchSlopDP(0.01).setStartRotation(0.001).setMinRotation(0.0015).setLongPressDuration(400L).setMinZoomSpan(400.0).setStartZoomSpan(400.0).setDebugModeEnabled(true).setIndirectInputDevice(true).build();
    }

    public static Configuration debug() {
        return newBuilder().setMinimumInertiaVelocity(0.4).setScrollTouchSlopDP(0.01).setStartRotation(0.001).setMinRotation(0.0015).setLongPressDuration(400L).setMinZoomSpan(400.0).setStartZoomSpan(400.0).setDebugModeEnabled(true).setIndirectInputDevice(true).setShowCursor(true).build();
    }

    public static Configuration properties() {
        try {
            return newBuilder((String) null).build();
        } catch (IOException | NumberFormatException var1) {
            System.out.println("Failed loading configuration from tuiofx.properties file — now using Debug Configuration ");
            return debug();
        }
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static Builder newBuilder(String filePath) throws NumberFormatException, IOException {
        return new Builder(filePath);
    }

    public Builder toBuilder() {
        return new Builder(this);
    }

    private Configuration(Builder builder) {
        this.port = builder.port;
        this.minimumInertiaVelocity = builder.minimumInertiaVelocity;
        this.startRotation = builder.startRotation;
        this.scrollTouchSlopDP = builder.scrollTouchSlopDP;
        this.minRotation = builder.minRotation;
        this.longPressDuration = builder.longPressDuration;
        this.minZoomSpan = builder.minZoomSpan;
        this.startZoomSpan = builder.startZoomSpan;
        this.debugModeEnabled = builder.debugModeEnabled;
        this.useIndirectInputDevice = builder.useIndirectInputDevice;
        this.showCursor = builder.showCursor;
        this.screenDevice = builder.screenDevice;

        this.handlerCursorEvent = builder.handlerCursorEvent;
    }

    public int getPort() {
        return this.port;
    }

    public boolean isDebugModeEnabled() {
        return this.debugModeEnabled;
    }

    public double getMinimumInertiaVelocity() {
        return this.minimumInertiaVelocity;
    }

    public double getStartRotation() {
        return this.startRotation;
    }

    public double getScrollTouchSlopDP() {
        return this.scrollTouchSlopDP;
    }

    public long getLongPressDuration() {
        return this.longPressDuration;
    }

    public boolean isUseIndirectInputDevice() {
        return this.useIndirectInputDevice;
    }

    public boolean isShowCursorEnabled() {
        return this.showCursor;
    }

    public int getScreenDevice() {
        return this.screenDevice;
    }

    public boolean isHandlerCursorEvent(){
        return this.handlerCursorEvent;
    }

    public static final class Builder {
        private static final String DEFAULT_PROPERTY_NAME = "tuiofx.properties";
        private int port;
        private double minimumInertiaVelocity;
        private double scrollTouchSlopDP;
        private double startRotation;
        private double minRotation;
        private long longPressDuration;
        private double minZoomSpan;
        private double startZoomSpan;
        private boolean debugModeEnabled;
        private boolean useIndirectInputDevice;
        private boolean showCursor;
        private int screenDevice;

        private boolean handlerCursorEvent;

        private Builder() {
            this.port = 3333;
            this.minimumInertiaVelocity = 0.4;
            this.scrollTouchSlopDP = 0.01;
            this.startRotation = 0.001;
            this.minRotation = 0.0015;
            this.longPressDuration = 400L;
            this.minZoomSpan = 7.999999797903001E-4;
            this.startZoomSpan = 7.5E-4;
            this.debugModeEnabled = false;
            this.useIndirectInputDevice = false;
            this.showCursor = false;
            this.screenDevice = 0;

            this.handlerCursorEvent = true;
        }

        private Builder(Configuration config) {
            this.port = config.port;
            this.minimumInertiaVelocity = config.minimumInertiaVelocity;
            this.startRotation = config.startRotation;
            this.scrollTouchSlopDP = config.scrollTouchSlopDP;
            this.minRotation = config.minRotation;
            this.longPressDuration = config.longPressDuration;
            this.minZoomSpan = config.minZoomSpan;
            this.startZoomSpan = config.startZoomSpan;
            this.debugModeEnabled = config.debugModeEnabled;
            this.useIndirectInputDevice = config.useIndirectInputDevice;
            this.showCursor = config.showCursor;
            this.screenDevice = config.screenDevice;

            this.handlerCursorEvent = config.handlerCursorEvent;
        }

        private Builder(String filePath) throws IOException, NumberFormatException {
            this.port = 3333;
            this.minimumInertiaVelocity = 0.4;
            this.scrollTouchSlopDP = 0.01;
            this.startRotation = 0.001;
            this.minRotation = 0.0015;
            this.longPressDuration = 400L;
            this.minZoomSpan = 7.999999797903001E-4;
            this.startZoomSpan = 7.5E-4;
            this.debugModeEnabled = false;
            this.useIndirectInputDevice = false;
            this.showCursor = false;
            this.screenDevice = 0;
            if (filePath == null || filePath.isEmpty()) {
                filePath = "tuiofx.properties";
            }

            Properties props = new Properties();
            BufferedInputStream stream = new BufferedInputStream(new FileInputStream(filePath));
            props.load(stream);
            stream.close();
            this.port = Integer.parseInt(props.getProperty("port"));
            this.minimumInertiaVelocity = Double.parseDouble(props.getProperty("minimumInertiaVelocity"));
            this.startRotation = Double.parseDouble(props.getProperty("minimumInertiaVelocity"));
            this.scrollTouchSlopDP = Double.parseDouble(props.getProperty("scrollTouchSlopDP"));
            this.minRotation = Double.parseDouble(props.getProperty("minRotation"));
            this.longPressDuration = Long.parseLong(props.getProperty("longPressDuration"));
            this.minZoomSpan = Double.parseDouble(props.getProperty("minZoomSpan"));
            this.startZoomSpan = Double.parseDouble(props.getProperty("startZoomSpan"));
            this.debugModeEnabled = Boolean.parseBoolean(props.getProperty("debugModeEnabled"));
            this.useIndirectInputDevice = Boolean.parseBoolean(props.getProperty("useIndirectInputDevice"));
            this.showCursor = Boolean.parseBoolean(props.getProperty("showCursor"));
            this.screenDevice = Integer.parseInt(props.getProperty("screenDevice"));

            this.handlerCursorEvent = Boolean.parseBoolean(props.getProperty("handlerCursorEvent"));
        }

        public Builder setMinimumInertiaVelocity(double minimumInertiaVelocity) {
            this.minimumInertiaVelocity = minimumInertiaVelocity;
            return this;
        }

        public Builder setScrollTouchSlopDP(double scrollTouchSlopDP) {
            this.scrollTouchSlopDP = scrollTouchSlopDP;
            return this;
        }

        public Builder setStartRotation(double startRotation) {
            this.startRotation = startRotation;
            return this;
        }

        public Builder setMinRotation(double minRotation) {
            this.minRotation = minRotation;
            return this;
        }

        public Builder setLongPressDuration(long longPressDuration) {
            this.longPressDuration = longPressDuration;
            return this;
        }

        public Builder setMinZoomSpan(double minZoomSpan) {
            this.minZoomSpan = minZoomSpan;
            return this;
        }

        public Builder setStartZoomSpan(double startZoomSpan) {
            this.startZoomSpan = startZoomSpan;
            return this;
        }

        public Builder setDebugModeEnabled(boolean debugModeEnabled) {
            this.debugModeEnabled = debugModeEnabled;
            return this;
        }

        public Builder setIndirectInputDevice(boolean useIndirectInputDevice) {
            this.useIndirectInputDevice = useIndirectInputDevice;
            return this;
        }

        public Builder setShowCursor(boolean showCursor) {
            this.showCursor = showCursor;
            return this;
        }

        public Builder setScreenDevice(int screenDevice) {
            this.screenDevice = screenDevice;
            return this;
        }

        public Builder setHandlerCursorEvent(boolean handlerCursorEvent) {
            this.handlerCursorEvent = handlerCursorEvent;
            return this;
        }

        public Configuration build() {
            return new Configuration(this);
        }
    }
}
